<?php

class Lite_Collection_NaturalComparator
	implements Lite_Collection_Comparator {
		
	/**
	 * @param mixed $var1
	 * @param mixed $var2
	 * @return int	 1 si $var1 > $var2
	 * 				 0 si $var1 = $var2
	 * 				-1 si $var1 < $var2
	 */
	public function compareTo($var1, $var2){
		$t1 = gettype($var1);
		$t2 = gettype($var2);
		if( $t1 != $t2 ) {
			# si los tipos son distintos, comparamos los tipos
			# no es lo mejor, pero funciona
			return $this->compareTo($t1, $t2);
		}
		
		return $var1 === $var2 ? 0 :( $var1 > $var2 ? 1 : -1 ); 
	}
	
	/**
	 * @param mixed $var1
	 * @param mixed $var2
	 * @return boolean
	 */
	public function equals($var1, $var2){
		return 0 === $this->compareTo($var1, $var2);
	}
}